#include <atomic>
#include <chrono>
#include <iostream>
#include <string>
#include <sys/epoll.h>
#include <thread>
#include <vector>
#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h> 
#include <fcntl.h> 
#include <sys/types.h>
#include <unistd.h>		/* read */


using namespace std;

class ac_object
{
	public:
		ac_object() {};
		~ac_object() {};

		int value;

	public:
		int read_value() 
		{
			return value;
		}

		void write_value(int v) 
		{
			value = v;
		}
};

class ac_communication
{
	public:
		ac_communication() {}
		~ac_communication() {}

		int open_device(void) 
		{
			fd = open("/dev/ttyUSB0", O_RDONLY );
			if (-1 == fd) {
				cout << "open device fail." << endl;
			}

			return fd;
		}

		int recv(int len, char *buffer) 
		{
			len = read(fd, buffer, len);
			return len;
		}
	
	public:
		int fd = -1;
};

int main()
{
	ac_object ac, ad;

	ac.value = 35;
	cout << "ac value is " << ac.read_value() << endl;	// 35

	ad.value = 22;
	cout << "ad value is " << ad.read_value() << endl;	// 22

	ac = ad;
	cout << "ac value is " << ac.read_value() << endl;	// 22

	ad.value = 56;
	cout << "ac value is " << ac.read_value() << endl;	// 22
	cout << "ad value is " << ad.read_value() << endl;	// 56

	ac.write_value(77);
	cout << "ac value is " << ac.read_value() << endl;	// 77
	cout << "ad value is " << ad.read_value() << endl;	// 56
}

